.TH "IPSEC_SAMEADDR" 3 "28 Nov 2000"
.SH NAME
ipsec_sameaddr, ipsec_addrcmp, ipsec_samesubnet, ipsec_addrinsubnet, ipsec_subnetinsubnet, ipsec_subnetishost, ipsec_samesaid, ipsec_sameaddrtype, ipsec_samesubnettype \- do comparisons for addresses, subnets, SA IDs and address families
.SH SYNOPSIS
.B "#include <libreswan.h>
.sp
.B "int sameaddr(const ip_address *a, const ip_address *b);"
.br
.B "int addrcmp(const ip_address *a, const ip_address *b);"
.br
.B "int samesubnet(const ip_subnet *a, const ip_subnet *b);"
.br
.B "int addrinsubnet(const ip_address *a, const ip_subnet *s);"
.br
.B "int subnetinsubnet(const ip_subnet *a, const ip_subnet *b);"
.br
.B "int subnetishost(const ip_subnet *s);"
.br
.B "int samesaid(const ip_said *a, const ip_said *b);"
.br
.B "int sameaddrtype(const ip_address *a, const ip_address *b);"
.br
.B "int samesubnettype(const ip_subnet *a, const ip_subnet *b);"
.SH DESCRIPTION
These functions do various comparisons and tests on the
.I ip_address
type and
.I ip_subnet
types.
.PP
.I Sameaddr
returns
non-zero
if addresses
.I a
and
.IR b
are identical,
and
.B 0
otherwise.
Addresses of different families are never identical.
.PP
.I Addrcmp
returns
.BR \-1 ,
.BR 0 ,
or
.BR 1
respectively
if address
.I a
is less than, equal to, or greater than
.IR b .
If they are not of the same address family,
they are never equal;
the ordering reported in this case is arbitrary
(and probably not useful) but consistent.
.PP
.I Samesubnet
returns
non-zero
if subnets
.I a
and
.IR b
are identical,
and
.B 0
otherwise.
Subnets of different address families are never identical.
.PP
.I Addrinsubnet
returns
non-zero
if address
.I a
is within subnet
.IR s
and
.B 0
otherwise.
An address is never within a
subnet of a different address family.
.PP
.I Subnetinsubnet
returns
non-zero
if subnet
.I a
is a subset of subnet
.IR b
and
.B 0
otherwise.
A subnet is deemed to be a subset of itself.
A subnet is never a subset of another
subnet if their address families differ.
.PP
.I Subnetishost
returns
non-zero
if subnet
.I s
is in fact only a single host,
and
.B 0
otherwise.
.PP
.I Samesaid
returns
non-zero
if SA IDs
.I a
and
.IR b
are identical,
and
.B 0
otherwise.
.PP
.I Sameaddrtype
returns
non-zero
if addresses
.I a
and
.IR b
are of the same address family,
and
.B 0
otherwise.
.PP
.I Samesubnettype
returns
non-zero
if subnets
.I a
and
.IR b
are of the same address family,
and
.B 0
otherwise.
.SH SEE ALSO
inet(3), ipsec_initaddr(3)
.SH HISTORY
Written for the FreeS/WAN project by Henry Spencer.
